package oj;

import java.util.Scanner;

public class Day14F {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        String[] str=s.split(" ");
        int[] month={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int day=0;
        if(isLeapYear(Integer.parseInt(str[0]))) {
            month[2]++;
        }
        for (int i = 1; i < Integer.parseInt(str[1]); i++) {
            day+=month[i];
        }
        day+=Integer.parseInt(str[2]);
        System.out.println(day);

    }
    public static boolean isLeapYear(int a){
        if(a%4==0&&a%100!=0 || a%400==0){
            return true;
        }
        return false;
    }
}
